<template>
  <div>
  <q-page class="cc-admin row">
    <div class="col bg-white shadow-2 q-pa-md q-ma-sm">
      <q-table
        flat color="primary"
        class="cross_table"
        separator="cell" :columns="columns" :data="list" row-key="id" :pagination.sync="pagination"
        :visible-columns="group" @request="query"
        :rows-per-page-options="[10,20,50,100]"
        :loading="loading" selection="multiple" :selected.sync="selected" >
        <template v-slot:top>
          <div class="row no-wrap full-width">
            <!--<q-input clearable outlined dense placeholder="请输入用户姓名搜索" class="on-left" debounce="500" v-model="name" >
              <template #append>
                <q-btn flat round icon="search" color="primary" @click="query" :loading="loading">
                  <q-tooltip>搜索</q-tooltip>
                </q-btn>
              </template>
            </q-input>
            <q-input clearable outlined dense placeholder="请输入用户ID搜索" class="on-left" debounce="500" v-model="user_id" >
              <template #append>
                <q-btn flat round icon="search" color="primary" @click="query" :loading="loading">
                  <q-tooltip>搜索</q-tooltip>
                </q-btn>
              </template>
            </q-input>
            <q-input clearable outlined dense placeholder="开始时间" class="on-left" debounce="500" v-model="start_time" >
              <template #append>
                <q-btn flat round icon="event" color="primary">
                  <q-popup-proxy cover transition-show="scale" transition-hide="scale">
                    <q-date v-model="proxyDateStart">
                      <div class="row items-center justify-end q-gutter-sm">
                        <q-btn label="取消" color="primary" flat v-close-popup />
                        <q-btn label="确定" color="primary" flat @click="save_start_time" v-close-popup />
                      </div>
                    </q-date>
                  </q-popup-proxy>
                </q-btn>
                <q-btn flat round icon="search2" color="primary" @click="query" :loading="loading">
                  <q-tooltip>搜索</q-tooltip>
                </q-btn>
              </template>
            </q-input>
            <q-input clearable outlined dense placeholder="结束时间" class="on-left" debounce="500" v-model="end_time" >
              <template #append>
                <q-btn flat round icon="event" color="primary">
                  <q-popup-proxy cover transition-show="scale" transition-hide="scale">
                    <q-date v-model="proxyDateEnd">
                      <div class="row items-center justify-end q-gutter-sm">
                        <q-btn label="取消" color="primary" flat v-close-popup />
                        <q-btn label="确定" color="primary" flat @click="save_end_time" v-close-popup />
                      </div>
                    </q-date>
                  </q-popup-proxy>
                </q-btn>
                <q-btn flat round icon="search" color="primary" @click="query" :loading="loading">
                  <q-tooltip>搜索</q-tooltip>
                </q-btn>
              </template>
            </q-input>
            <q-space />-->
            <div class="q-gutter-xs">
               <q-btn icon="add" no-wrap color="primary" label="新建" @click="addTicket" />
              <q-btn icon="mdi-restore" no-wrap color="primary" label="刷新" @click="refresh" />
            </div>
          </div>
        </template>

        <template #body-cell-type="props">
          <q-td  key="type" :props="props">{{ typetran(props.row.type) }}</q-td>
        </template>

        <template #body-cell-is_del="props">
          <q-td  key="is_del" :props="props">{{getGoodsLabel(props.row.is_del) }}</q-td>
        </template>

        <template #body-cell-opt="props">
          <q-td :props="props" :auto-width="true">
            <q-btn flat round dense color="primary" icon="view_list" @click="detail(props.row.id)">
              <q-tooltip>详情</q-tooltip>
            </q-btn>
            <q-btn flat round dense color="red-14" icon="delete" @click="deleteRow(props.row.id)">
              <q-tooltip>删除</q-tooltip>
            </q-btn>
          </q-td>
        </template>

      </q-table>
    </div>


 <q-dialog maximized flat persistent ref="dialog">
      <q-form @submit="onSubmit" class="dialog_card column" @reset="onReset">
        <h5 class="view_title justify-between q-px-md">
          {{editType}}优惠券
          <q-btn dense outline round icon="clear" size="sm" v-close-popup />
        </h5>
        <q-scroll-area class="col">
          <div class="col q-col-gutter-x-md dialog_form q-pa-md">
            <div class="col-6" style="width:50%">
              <q-toolbar class="  text-black-12 rounded-borders">
                <span style="width:120px;">优惠券名称：</span>
                <q-input square outlined dense standout v-model="form.name" input-class="text-left rounded-borders"
                         :rules="[val => !!val || '优惠券名称是必填项']" class="q-ml-md col-10" >
                  <template v-slot:append>
                    <q-icon v-if="form.name!==''" class="cursor-pointer" name="close" @click="form.name = ''"/>
                    <q-icon v-if="form.name===''" class="cursor-pointer" name="close" @click="form.name = ''"/>
                  </template>
                </q-input>
              </q-toolbar>
            </div>

            <div class="row-3" style="width:50%">
              <q-toolbar class="  text-black-12 rounded-borders">
                <span style="width:120px;">金额：</span>
                <q-input square outlined dense standout v-model="form.value" input-class="text-left rounded-borders"
                         :rules="[val => !!val || '金额是必填项']" class="q-ml-md col-10" >
                  <template v-slot:append>
                    <q-icon v-if="form.value!==''" class="cursor-pointer" name="close" @click="form.value = ''"/>
                    <q-icon v-if="form.value===''" class="cursor-pointer" name="close" @click="form.value = ''"/>
                  </template>
                </q-input>
              </q-toolbar>
            </div>

            <div class="col-11">
                <q-toolbar class="  text-black-12 rounded-borders">
                  <span style="width:120px;">使用开始时间：</span>
                  <q-input filled v-model="form.start_time">
                    <template v-slot:prepend>
                      <q-icon name="event" class="cursor-pointer">
                        <q-popup-proxy cover transition-show="scale" transition-hide="scale">
                          <q-date v-model="form.start_time" mask="YYYY-MM-DD HH:mm">
                            <div class="row items-center justify-end">
                              <q-btn v-close-popup label="关闭" color="primary" flat />
                            </div>
                          </q-date>
                        </q-popup-proxy>
                      </q-icon>
                    </template>

                    <template v-slot:append>
                      <q-icon name="access_time" class="cursor-pointer">
                        <q-popup-proxy cover transition-show="scale" transition-hide="scale">
                          <q-time v-model="form.start_time" mask="YYYY-MM-DD HH:mm" format24h>
                            <div class="row items-center justify-end">
                              <q-btn v-close-popup label="关闭" color="primary" flat />
                            </div>
                          </q-time>
                        </q-popup-proxy>
                      </q-icon>
                    </template>
                  </q-input>
                </q-toolbar>
            </div>
            <div class="col-4">
                <q-toolbar class="  text-black-12 rounded-borders">
                  <span style="width:120px;">使用结束时间：</span>
                  <q-input filled v-model="form.end_time">
                    <template v-slot:prepend>
                      <q-icon name="event" class="cursor-pointer">
                        <q-popup-proxy cover transition-show="scale" transition-hide="scale">
                          <q-date v-model="form.end_time" mask="YYYY-MM-DD HH:mm">
                            <div class="row items-center justify-end">
                              <q-btn v-close-popup label="关闭" color="primary" flat />
                            </div>
                          </q-date>
                        </q-popup-proxy>
                      </q-icon>
                    </template>
                    <template v-slot:append>
                      <q-icon name="access_time" class="cursor-pointer">
                        <q-popup-proxy cover transition-show="scale" transition-hide="scale">
                          <q-time v-model="form.end_time" mask="YYYY-MM-DD HH:mm" format24h>
                            <div class="row items-center justify-end">
                              <q-btn v-close-popup label="关闭" color="primary" flat />
                            </div>
                          </q-time>
                        </q-popup-proxy>
                      </q-icon>
                    </template>
                  </q-input>
                </q-toolbar>
            </div>

            <div class="col-11" style="width:23%">
              <q-toolbar class="text-black-12 rounded-borders">
                <span style="width:120px;">兑换积分：</span>
                  <q-input square outlined dense standout v-model="form.point" type="number" input-class="text-left rounded-borders"  style="max-width:90%;float: left;"/>
                </q-toolbar>
            </div>


            <div class="col-11" style="width:23%">
              <q-toolbar class="text-black-12 rounded-borders">
                <span style="width:120px;">商户ID：</span>
              <q-input outlined dense v-model="form.seller_id" type="number" />
              </q-toolbar>
            </div>

            <div class="col-11" style="width:31%">
              <q-toolbar class="text-black-12 rounded-borders">
                <span style="width:120px;">优惠券类型：</span>
              <q-select style="width:300px;" outlined dense map-options v-model="form.type" :options="typeArr"
              @input="onValueChange" ></q-select>
              </q-toolbar>
            </div>

            <div class="col-9" style="width:31%">
              <q-toolbar class="text-black-12 rounded-borders">
                <span style="width:120px;">条件值：</span>
                <q-input style="width:300px;"  outlined dense v-model="form.condition" type="number" />
              </q-toolbar>
            </div>

            <div class="col-9">
              <q-toolbar class="text-black-12 rounded-borders">
                <span style="width:120px;">发券数量：</span>
              <q-input outlined dense v-model="form.limit_sum" type="number" />
              </q-toolbar>
            </div>

            <div class="col-9">
                <q-toolbar class="text-black-12 rounded-borders">
                  <span style="width:120px;">用户ID：</span>
                    <q-input outlined dense v-model="form.user_id" type="number" />
                </q-toolbar>
            </div>

            <div class="col-9">
              <q-toolbar class="text-black-12 rounded-borders">
                <span style="width:120px;">封面图：</span>
                <q-btn round @click="importAvatar">
                  <div size="100px">
                    <q-img style="width:100px;height:100px;" :src="imagePath(form.img)"></q-img>
                  </div>
                  <q-uploader auto-upload ref="avatarUploader" :max-files="1" class="hidden"
                    fieldName="file" :headers="headers" accept="image/*" :url="uploadUrl" field-name="file" @uploaded="importedAvatar" />
                  <q-tooltip>点击上传图片</q-tooltip>
                </q-btn>
              </q-toolbar>
            </div>

            <div class="col-9">
              <q-toolbar class="text-black-12 rounded-borders">
                <span style="width:120px;">简介：</span>
                <q-input  outlined dense v-model="form.intro" autogrow />
              </q-toolbar>
            </div>

            <div class="col-9">
                <q-toolbar class="text-black-12 rounded-borders">
                  <span style="width:120px;">最小值：</span>
                  <q-input  outlined dense v-model="form.min_value" type="number" />
                </q-toolbar>
            </div>
          </div>

        </q-scroll-area>
        <div class="row justify-center q-pa-md">
          <q-btn outline color="primary" icon="mdi-close-thick" label="关闭" v-close-popup />
          <q-btn class="q-mx-sm" color="primary" icon="mdi-check-bold" label="提交" type="submit" />
        </div>
      </q-form>
    </q-dialog>

    <confirm ref="confirmDialog" :msg="confirmMsg" @confirm="deleteBatch()" />

  </q-page>

  <!-- 详情 ----------------------------- -->
  <q-dialog v-model="dialogdetialVisible" maximized flat persistent>
      <q-form  class="dialog_card column">
        <h5 class="view_title justify-between q-px-md">
          详情
          <q-btn dense outline round icon="clear" size="sm" v-close-popup />
        </h5>
        <q-scroll-area class="col">
            <div class="row q-col-gutter-x-md dialog_form q-pa-md">
              <div class="col-11">
                <h5>优惠券名称：</h5>
                <q-input outlined dense v-model="form.name" type="text" disable  />
              </div>

              <div class="col-11">
                <h5>金额:</h5>
                <q-input outlined dense v-model="form.value"    :rules="[phoneTest]" />
              </div>

              <div class="col-11">
                <h5>使用时间:</h5>
                <q-input outlined dense v-model="form.start_time"   disable />
                <q-input outlined dense v-model="form.end_time"     disable style="margin-top: 20px;" />
              </div>

              <div class="col-11">
                <h5>需要兑换的积分数:</h5>
                <q-input outlined dense v-model="form.point"   disable />
              </div>

              <div class="col-11">
                <h5>商户ID:</h5>
                <q-input outlined dense v-model="form.seller_id"   disable />
              </div>

              <div class="col-11">
                <h5>优惠券类型:</h5>
                <q-input outlined dense v-model="form.type"   disable />
              </div>

              <div class="col-11">
                <h5>条件值:</h5>
                <q-input outlined dense v-model="form.condition"   disable />
              </div>

              <div class="col-11">
                <h5>用户ID:</h5>
                <q-input outlined dense v-model="form.user_id"   disable />
              </div>

              <div class="col-11">
                <h5>封面图:</h5>
                <div >
                    <q-img style="width:100px;height:100px;" :src="imagePath(form.img)"></q-img>
                </div>
              </div>

              <div class="col-11">
                <h5>简介:</h5>
                <div >
                    <q-input v-model="form.intro" filled outlined autogrow  disable />
                </div>
              </div>
              <div class="col-11">
                <h5>最小值:</h5>
                <div >
                    <q-input v-model="form.min_value" filled outlined autogrow  disable />
                </div>
              </div>
            </div>
        </q-scroll-area>
         <div class="row justify-center q-pa-md">
          <q-btn outline color="primary" icon="mdi-close-thick" label="关闭" v-close-popup />
        </div>
        </q-form>
  </q-dialog>
  <!-- 详情 end ...  -->
  <q-dialog v-model="dialogNewVisible"  persistent :full-height="false">
      <q-layout view="Lhh lpR fff" container class="bg-white" style="height:560px;padding-left: 20px;">
          <q-header class="bg-primary">
            <q-toolbar>
              <q-toolbar-title v-if="isEdit==0">添加红包</q-toolbar-title>
              <q-toolbar-title v-if="isEdit==1">编辑红包</q-toolbar-title>
              <q-btn flat v-close-popup round dense icon="close" />
            </q-toolbar>
          </q-header>
          <q-form style="padding-top: 50px;">
            <q-card style="width: 560px;height:460px; padding-left: 30px;">
              <h5 class="view_title justify-between q-px-md">
                <span v-if="isEdit ==0">添加红包</span>
                <span v-if="isEdit ==1">编辑红包</span>
                <q-btn dense outline round icon="clear" size="sm" v-close-popup />
              </h5>
              <div class="q-col-gutter-x-md dialog_form q-pa-md" style="padding: 0 10px;width:260px;">
                <div class="col-4">
                  <h5>红包名称:</h5>
                  <q-input outlined dense v-model="form.name" disable />
                </div>
              </div>
                <div class="q-col-gutter-x-md dialog_form q-pa-md" style="padding: 0 10px;width:260px;" >
                  <div class="col-4">
                    <h5>红包金额:</h5>
                    <q-input outlined dense v-model="form.value" />
                  </div>
                </div>
              <div>
                <q-btn  color="primary" label="保存" style="width:120px;margin: 0 5px;" @click="saveTicket(0)"/>
                <q-btn  color="primary" label="保存并继续" style="width:120px;margin: 0 5px;" @click="saveTicket(1)"/>
                <q-btn outline color="primary" icon="mdi-close-thick"  style="width:120px;"  label="关闭" v-close-popup />
              </div>
            </q-card>
          </q-form>
      </q-layout>
  </q-dialog>

</div>
</template>
<!-- --优惠券列表------------------------ -->
<script>
import { IndexMixin } from 'boot/mixins';
import { getDictLabel } from 'boot/dictionary';
import confirm from 'components/confirm';
import { requiredTest, moneyRules ,phoneTest } from 'boot/inputTest';
import catalogselect from 'components/catalogselect';
import viewcatalog from 'components/viewcatalog';
import { ref } from 'vue'


export default {
  name: 'MntDeploy',
  mixins: [IndexMixin],
  components: {
    confirm,
    catalogselect,
  },
  data() {
    return {
      text: '',
      dialogdetialVisible:false,
      dialogNewVisible: false,
      description:'',
      typej: { 0:"全品类", 1:"只用于某个商品", 2:"只用某分类", 3:"固定红包", 4:"随机红包", 5:"系统发放" },
      typej2: [ {value: '0', label: '全品类'}, {value: '1', label: '只用于某个商品'}, {value: '2', label: '只用某分类'}, {value: '3', label: '固定红包'},
        {value: '4', label: '随机红包'}, {value: '5', label: '微信红包'} ],
      typeArr:[],
      ticketTypeArr:[],
      form: {
          id: '',
          name: '系统红包',
          type: 0,
          value: '',
          min_value: '',
          point: 0,
          seller_id: 0,
          img: '',
          condition: 0,
          limit_sum: 0,
          user_id: 0,
          intro: '',
          start_time: ref(new Date().toLocaleDateString().split('/').join('-')),
          end_time: ref(new Date().toLocaleDateString().split('/').join('-')),
      },
      columns: [
        { name: 'id', align: 'center', label: '序号', field: 'id', },
        // { name: 'name', align: 'center', label: '名称', field: 'name', },
        { name: 'value', align: 'center', label: '优惠券金额', field: 'value', },
        { name: 'start_time', align: 'center', label: '开始时间', field: 'start_time', },
        { name: 'end_time', align: 'center', label: '结束时间', field: 'end_time', },
        { name: 'type', align: 'center', label: '类型', field: 'type', },,
        { name: 'opt', align: 'center', label: '操作', field: 'id', }
      ],
      showQuery: true,
      headers: [{ name: 'Authorization', value: localStorage.Authorization }],
      uploadUrl: `${process.env.BASE_URL}/uploadfile`,
      imgUrl: `http://img.tel.gzzsu.com`,
      url: {
        list: '/ticketlist',
        add: '/ticketadd',
        edit: '/ticketupdate',
        detail: '/ticketdetail',
        delete: '/ticketdelete',
      },
      isEdit: 0,
      modelList: [],
      user_id: null,
      start_time: '',
      end_time: '',
      name: '',
      proxyDateStart: '2023/12/06',
      proxyDateEnd: '2023/12/06',
      rowsNumber: 1,
      rowsPerPage: 10,
    };
  },
  methods: {
    addTicket() {
      this.form.value = ""
      this.isEdit = false
      this.dialogNewVisible = true
    },
    save_start_time() {
      this.start_time = new Date(this.proxyDateStart).format("yyyy-MM-dd")
    },
    save_end_time() {
      this.end_time = new Date(this.proxyDateEnd).format("yyyy-MM-dd")
    },
    onValueChange(val) {
      console.log("447 >>>>>>>",val);
    },
    refresh(){
      this.$axios.post('/ticketlist', {page: this.rowsNumber, limit: this.rowsPerPage}).then((r) => {
        this.list = r.data;
      });
    },
    detail(id) {
      this.$axios.post(this.url.detail, {id:  id}).then( (r) => {
          this.form = r.data
          this.dialogNewVisible = true
        this.isEdit = true
        }
      );
    },
    requiredTest,moneyRules ,phoneTest,
    addBefore() {
      this.form.catalogId = this.catalog;
      return true;
    },
    selectCatalog(n) {
      this.catalog = n;
      this.query();
    },
    selectFiles() {
      this.$refs.fileUploader.pickFiles();
    },
    importAvatar() {
      this.$refs.avatarUploader.pickFiles();
    },
    importedAvatar({ xhr }) {
      const response = JSON.parse(xhr.responseText);
      if (response.code == 0) {
        this.form.img = response.data.url
        console.log(this.form.ad_img)
        this.$q.notify('上传成功');
      } else {
        this.$q.notify({
          color: 'red',
          message: '上传失败',
        });
      }
      this.$refs.avatarUploader.removeUploadedFiles();
    },
    uploadedFiles({ xhr }) {
      const response = JSON.parse(xhr.responseText);
      if (response.success) {
        this.$q.notify('上传成功');
        this.queryImages();
      } else {
        this.$q.notify({
          color: 'red',
          message: '上传失败',
        });
      }
      this.$refs.fileUploader.removeUploadedFiles();
    },
    imagePath(src) {
      let path = '';
      if (src) {
        if (src.startsWith('http')) {
          return src;
        }
        path = `${this.imgUrl}/${src}`;
      }
      return path;
    },
    queryImages() {
      // this.$axios.get(`/sys/file/listByMainId?mainId=${this.form.id}`).then(({ result }) => {
      //   this.attachments = result;
      // });
    },
    getGoodsLabel(status){
      const list = {
        menuType: [0 , 1, 2 ],
        icon: ['正常', '删除' ],
      };
      const showStatus = ['正常', '删除' ];
      return showStatus[status]
    },
    typetran(val) {
      return this.typej[val];
    },
    initDict() {

    },
    deploy() {
      this.$refs.keyFileUploader.pickFiles();
    },
    importedDeploy({ xhr }) {
      this.$refs.keyFileUploader.removeUploadedFiles();
      const { response } = xhr;
      const res = JSON.parse(response);
      if (res.success) {
        this.form.keyFile = res.message;
      } else {
        this.$error(res.message);
      }
    },
    sysRestore() {
      this.$refs.sysRestore.dialog = true;
    },
    handlerSelect() {
      alert('560');
    },
    saveTicket(type) {
      var url = ""
      if(this.form.value.length == 0){
        this.$q.notify({
          color: 'red',
          message: '红包金额不能为空！',
        });
        return
      }else{
        if(this.isEdit == 1){
          url = this.url.edit
        }else{
          url = this.url.add
        }
      }
      this.form.name = "系统红包"
      this.$axios.post(url,this.form).then((r) => {
        this.babyWord = r;
        if(r.success = true){
          this.$q.notify({ position: 'top', color: 'info', textColor: 'white', icon: 'cloud_done', group: false, html: true, message: '保存成功！！',});
          this.refresh()
          if(type == 0){
            // 保存并且继续添加红包
            this.onReset()
            this.dialogNewVisible = false;
          }
        }else{
          this.$q.notify({ position: 'top', color: 'error', textColor: 'red', icon: 'cloud_done', group: false, html: true, message: '保存失败！！',});
        }
      });
    },
    onSubmit (evt) {
      console.log( this.form  )
      let url = ''
      if (this.form.start_time > this.form.end_time  ) {
        return this.$q.notify({
          color: 'red',
          message: '起始时间必须大于截止时间!',
        });
      }

      if(this.form.store_nums < 0){
        this.$q.notify({
          color: 'red',
          message: '商品库存不能小于0',
        });
        return
      }else{
        if(this.isEdit == 1){
          url = this.url.edit
        }else{
          url = this.url.add
        }
        // this.$axios.post(url,this.form).then((r) => {
        //   this.babyWord = r;
        //   if(r.success = true){
        //     this.$q.notify({ position: 'top', color: 'info', textColor: 'white', icon: 'cloud_done', group: false, html: true, message: '保存成功！！',});
        //     this.onReset()
        //     this.refresh()
        //     this.$refs.dialog.hide();
        //   }else{
        //     this.$q.notify({ position: 'top', color: 'error', textColor: 'red', icon: 'cloud_done', group: false, html: true, message: '保存失败！！',});
        //   }
        // });
      }

      //evt.target.submit()
    },
    onReset(){
      this.form = {
        name : '' ,
        mobile : '',
        telephone : '',
        tag : '',
        remark : '',
      }
    },
    queryParam() {
      //组合查询参数
      const data={};
      if (this.user_id >0) {
        data['user_id'] = this.user_id;
      }
      if (this.name.length > 0) {
        data['name'] = this.name;
      }
      if (this.start_time != ''){
        data['start_time'] = this.start_time;
      }
      if (this.end_time != ''){
        data['end_time'] = this.end_time;
      }
      this.searchForm = data;
    },
    //时间函数
    datatime(){
      Date.prototype.format = function(format){
        const o = {
          'M+': this.getMonth() + 1, //month
          'd+': this.getDate(), //day
          'h+': this.getHours(), //hour
          'm+': this.getMinutes(), //minute
          's+': this.getSeconds(), //second
          'q+': Math.floor((this.getMonth() + 3) / 3), //quarter
          'S': this.getMilliseconds() //millisecond
        };
        if(/(y+)/.test(format)) {
          format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
        }
        for(var k in o) {
          if(new RegExp("("+ k +")").test(format)) {
            format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
          }
        }
        return format;
      }
    },
    deleteRow(id) {
      this.loading = true;
      if(window.confirm("确定要删除吗")){
        return this.$axios.post(this.url.delete, {   ids: id   }).then((r) => {
          this.$info(r.msg);
          this.loading = false;
        }).finally(() => {
          this.query();
        });
      }
      this.loading = false;
    }
  },
  mounted() {
    this.initDict();
    this.typeArr = Object.values(this.typej)
    // this.form.start_time = new Date().toLocaleDateString().split('/').join('-');
    // this.form.end_time = new Date().toLocaleDateString().split('/').join('-');
    this.datatime();
  },
};
</script>

<style lang="stylus"></style>
